home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / bbs / cddk9606.zip / HEADERS.ARJ / REBOOT.INT < prev    next >
Text File  |  1996-06-14  |  6KB  |  171 lines

  1.  
  2. { ───────────────────────────────────────────────────────────────────────── }
  3. {  REBOOT: Routines to reboot the computer                                  }
  4. {  Copyright 1996 David Pinch ∙ All Rights Reserved Worldwide               }
  5. { ───────────────────────────────────────────────────────────────────────── }
  6.  
  7. UNIT Reboot;
  8.  
  9. {$B-} { . . . . . . . . . . . . . . . . . . . . Shortcut boolean evaluation }
  10. {$F+} { . . . . . . . . . . . . . . . . . . . .  Force far calls for safety }
  11. {$I-} { . . . . . . . . . . . . . . . . . . . Disable input/output checking }
  12. {$O+} { . . . . . . . . . . . . . . . . . . Allow this unit to be overlayed }
  13. {$Q-} { . . . . . . . . . . . . . .  Do not generate overflow-checking code }
  14. {$R-} { . . . . . . . . . . . . . . . . Do not generate range-checking code }
  15. {$S-} { . . . . . . . . . . . . . . . . Do not generate stack-checking code }
  16. {$X+} { . . . . . . . . . . . Extended syntax for pChars and function calls }
  17.  
  18. INTERFACE
  19.  
  20. {#Start}
  21.  
  22. PROCEDURE GenerateRebootCom(p:pChar);
  23.   {
  24.   PURPOSE  : Generates a COM (executable) file that will invoke a hardware
  25.              reset of the CPU.
  26.  
  27.   NOTES    : Such a program may be useful if your door uses any external
  28.              batch files (i.e. add-on modules) and you wish to give the
  29.              sysop the option of rebooting the computer in the event of an
  30.              emergency.
  31.  
  32.              This command is very dangerous.  Use with care.
  33.  
  34.   EXAMPLE  : PROCEDURE MakeBatch;
  35.                VAR
  36.                  Batch : Text;
  37.                BEGIN
  38.                GenerateRebootCom('REBOOT.COM');
  39.                Assign(Batch,'RunIGM.Bat');
  40.                Rewrite(Batch);
  41.                WriteLn(Batch);
  42.                WriteLn(Batch,'REM  This is a temporary batch file created');
  43.                WriteLn(Batch,'REM  by the door when running an IGM.  You');
  44.                WriteLn(Batch,'REM  may safely delete this file if the door');
  45.                WriteLn(Batch,'REM  is shut down on all nodes.');
  46.                WriteLn(Batch);
  47.                WriteLn(Batch,'IF %1~ = ~ GOTO Done');
  48.                WriteLn(Batch,'%2.EXE %3 %4 %5);
  49.                WriteLn(Batch,'IF ERRORLEVEL 69 REBOOT.COM
  50.                WriteLn(Batch,':Done');
  51.                WriteLn(Batch,'IF FILE EXIST REBOOT.COM DEL REBOOT.COM');
  52.                Close(Batch);
  53.                END;
  54.  
  55.   SEE ALSO : RebootComputer
  56.   }
  57.  
  58.  
  59. PROCEDURE RebootComputer(c:Char);
  60.   {
  61.   PURPOSE  : Executes the selected reboot.
  62.  
  63.   PARAMS   : ┌─────┬──────────┐
  64.              │  c  │  Method  │
  65.              ├─────┼──────────┤
  66.              │  c  │   Cold   │
  67.              │  h  │ Hardware │
  68.              │  r  │ Hardware │
  69.              │  w  │   Warm   │
  70.              └─────┴──────────┘
  71.  
  72.   NOTES    : a. The c parameter is not case sensitive.
  73.              b. The hardware reset method requires a 286 or later.
  74.              c. The cold and warm reboot methods may cause a general
  75.                 protection fault (GPF) under some multitaskers.
  76.  
  77.   EXAMPLE  : BEGIN
  78.              WriteLn('WARNING: The computer will now reboot the PC.');
  79.              WriteLn('Please shut down all applications, then select');
  80.              WriteLn('the desired reboot method.');
  81.              WriteLn;
  82.              WriteLn(' C = Cold Reboot');
  83.              WriteLn(' H = Hardware Reset (286+)');
  84.              WriteLn(' W = Warm Reboot (skips memory test)');
  85.              WriteLn;
  86.              ReadLn(Method);
  87.              RebootComputer(Method);
  88.              WriteLn('REBOOT FAILURE!  Please contact the author.');
  89.              END;
  90.  
  91.   SEE ALSO : ColdReboot, HardwareReset, WarmReboot
  92.   }
  93.  
  94.  
  95. PROCEDURE ColdReboot;
  96.   {
  97.   PURPOSE  : Invokes a cold reboot.
  98.  
  99.   NOTES    : A cold reboot is the same as a full reset of the computer
  100.              computer system.  Compare this to the warm reboot, which
  101.              generally skips the initial memory test.
  102.  
  103.   EXAMPLE  : BEGIN
  104.              SO_pCharLn('Please prepare for a system reboot.');
  105.              IF SI_Boolean('Skip initial memory test? ',False) THEN
  106.                WarmReboot
  107.              ELSE
  108.                ColdReboot;
  109.              END;
  110.  
  111.   SEE ALSO : RebootComputer, HardwareReset, WarmReboot
  112.   }
  113.  
  114.  
  115. PROCEDURE HardwareReset;
  116.   {
  117.   PURPOSE  : Uses the 8042 keyboard controller chip to invoke a CPU reset.
  118.              This procedure requires a 286+ and an enhanced keyboard.
  119.  
  120.   NOTES    : This procedure will bypass your operating system.  All
  121.              concurrent tasks will be lost.  Be sure to warn the operator
  122.              before using this (or any other) reboot procedure.
  123.  
  124.   EXAMPLE  : BEGIN
  125.              IF System.Test8086 > 0 THEN
  126.                HardwareReset
  127.              ELSE
  128.                WriteLn('Error: 286+ not detected.');
  129.              END;
  130.  
  131.   SEE ALSO  : RebootComputer, ColdReboot, WarmReboot
  132.   }
  133.  
  134.  
  135. PROCEDURE WarmReboot;
  136.   {
  137.   PURPOSE  : Invokes a warm reboot on the computer system.
  138.  
  139.   NOTES    : A warm reboot will the skip the initial memory test on
  140.              most computer systems.  This procedure may cause problems
  141.              in some multitasked and networked enviroments.
  142.  
  143.   EXAMPLE  : PROCEDURE SystemHasCrashed;
  144.                VAR
  145.                  Loop : Byte;
  146.                BEGIN
  147.                WriteLn('The program is unable to recover from a fatal');
  148.                WriteLn('error.  Rather than return to the BBS and risk');
  149.                WriteLn('further damage to your system, the computer will');
  150.                WriteLn('now reboot.  This will allow your AUTOEXEC.BAT');
  151.                WriteLn('file to restart the BBS.');
  152.                WriteLn;
  153.                FOR Loop:=5 DOWNTO 1 DO
  154.                  BEGIN
  155.                  Write(Loop,' ');
  156.                  Ring;
  157.                  Delay(1000);
  158.                  END;
  159.                WarmReboot;
  160.                END;
  161.  
  162.   SEE ALSO : RebootComputer, ColdBoot, HardwareReset
  163.   }
  164.  
  165.  
  166. IMPLEMENTATION
  167.  
  168. { The source code is available upon registration. }
  169.  
  170. END.
  171.